//
//  CWQ_courseIntroductionCell.m
//  BaxTer
//
//  Created by 陈武琦 on 16/9/1.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "CWQ_courseIntroductionCell.h"
#import "UIImageView+BTimageView.h"
#import "HCSStarRatingView.h"
#import "UILabel+ResolveNull.h"
@implementation CWQ_courseIntroductionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
//    [self.leftIcon yy_setImageWithURL:[NSURL URLWithString:@"http://image.tianjimedia.com/uploadImages/2015/129/56/J63MI042Z4P8.jpg"] placeholder:[UIImage imageNamed:@"暂无图片.jpg"] options:YYWebImageOptionProgressive | YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation completion:nil];
  
    self.starRatingView.userInteractionEnabled = NO;
 
    self.praiseL.hidden = YES;
    self.praseIcon.hidden = YES;
}


- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated

{
    
    UIColor *backgroundColor = [UIColor clearColor];
    
    [super setHighlighted:highlighted animated:animated];
    
    //重点代码
    for (UIView *view in [self.contentView subviews]) {
        if ([view isKindOfClass:[UIImageView class]]) {
            view.backgroundColor = backgroundColor;
        }
    }
    
    
}

- (void)setHotModel:(BTHotListModel *)model{
    _hotModel = model;
    [self.leftIcon bt_setImageWithUrl:model.contentImageUrl];
    
    self.titleL.text = model.name;
    if (model.courseScore) {
        self.starRatingView.value = [model.courseScore floatValue] /2;
        self.scoreL.text = [NSString stringWithFormat:@"%@分",model.courseScore];
    }else{
        self.starRatingView.value = 0;
        self.scoreL.text = [NSString stringWithFormat:@"0分"];
    }
    self.number.wsj_text = [NSString stringWithFormat:@"%@",model.clickNum];
    
    self.state.text = [NSString stringWithFormat:@"状态%@", model.courseStatus];
    self.date.hidden =YES;
    self.is_learn.hidden = YES;
    NSString *stateStr;
    switch ([model.courseStatus integerValue]) {
        case 0:
            stateStr = @"未开始";
            break;
        case 1:
            stateStr = @"未学完";
            break;
        case 2:
            stateStr = @"待评分";
            break;
        case 3:
            stateStr = @"未测试";
            break;
        case 4:
            stateStr = @"已完成";
            break;
            
        default:
            break;
    }
    
    if ([model.generalizeType integerValue] == 1) {
         self.state.text = stateStr;
        self.state.hidden = NO;
    }else{
        self.state.hidden =YES;
    }
   
    
}

- (void)setCourseModel:(BTCourseModel *)model
{
    _courseModel  = model;
    [self.leftIcon bt_setImageWithUrl:model.courseImage];
    
    self.praiseL.hidden = NO;
    self.praseIcon.hidden = NO;
    self.praiseL.wsj_text = [NSString stringWithFormat:@"%@",model.courseLikeCount];
    
    self.titleL.text = model.courseName;
    if (model.courseScore) {
        self.starRatingView.value = [model.courseScore floatValue] /2;
        self.scoreL.text = [NSString stringWithFormat:@"%@分",model.courseScore];
    }else{
        self.starRatingView.value = 0;
        self.scoreL.text = [NSString stringWithFormat:@"0分"];
    }
    self.number.wsj_text = [NSString stringWithFormat:@"%@",model.viewNum];
    
    self.state.text = [NSString stringWithFormat:@"状态%@", model.courseStatus];
    if (self.tagKey && [self.tagKey isEqualToString:@"download"]) {
        //过期时间
        self.date.text =[NSString stringWithFormat:@"%@天后过期",model.expireDays] ;
        self.date.hidden = YES;
    }else{
        self.date.hidden = YES;
    }
   
    if (self.needShowGaizhang) {
        if ([model.courseStatus integerValue] == 4) {
            self.is_learn.hidden = NO;
        }else{
            self.is_learn.hidden = YES;
        }
    }else{
        self.is_learn.hidden = YES;
    }
    
    NSString *stateStr;
    switch ([model.courseStatus integerValue]) {
//            0：表示未开始
//            1：表示未学完，主要针对图文和视频。微课和长图可以略过这个状态。
//            2：表示待评分。
//            3：表示待测试，评分完未测试的课程。仅针对有测试的课程，
//            4：表示已完成
        case 0:
            stateStr = @"未开始";
            break;
        case 1:
            stateStr = @"未学完";
            break;
        case 2:
            stateStr = @"待评分";
            break;
      
        case 3:
            stateStr = @"待测试";
            break;
        case 4:
            stateStr = @"已完成";
            break;
            
        default:
            break;
    }
   
    self.state.text = stateStr;
    
  
}
- (void)setTopicModel:(BTTopicListModel *)model{
    _topicModel = model;
    [self.leftIcon bt_setImageWithUrl:model.topicImage];
    
    self.titleL.text = model.topicname;
//    if (model.courseScore) {
//        self.starRatingView.value = [model.courseScore floatValue] /2;
//        self.scoreL.text = [NSString stringWithFormat:@"%@分数",model.courseScore];
//    }
    self.starRatingView.hidden = YES;
    self.scoreL.hidden =YES;
    self.number.text = [NSString stringWithFormat:@"%@",model.topicclickcount];
    
    self.state.hidden =YES;
    //过期时间
    self.date.hidden =YES;
    
    if (self.needShowGaizhang) {
        if ([model.topicStatus integerValue] == 0) {
            self.is_learn.hidden = YES;
        }else{
            self.is_learn.hidden = NO;
        }
    }else{
      self.is_learn.hidden = YES;
    }
    
   
    self.praseIcon.hidden = NO;
    self.praiseL.hidden = NO;
    self.praiseL.wsj_text = [NSString stringWithFormat:@"%@",model.topiclikecount];
    
    
}

@end
